package com.web.service.impl;


import com.web.entity.User;
import com.web.mapper.UserMapper;
import com.web.service.UserService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

/**
 * @author: XiangHu
 * @date: 2025年03月03日 16:48
 * @describe: 学生服务实现类
 */
/*public class UserServiceImpl implements UserService {

    private UserDAO userDAO = new UserDAOImpl();

    @Override
    public User login(String username, String password) {
        return userDAO.selectUserByUsername(username);
    }
}*/
    @Service
public class UserServiceImpl implements UserService {

    //创建dao对象
   @Resource
    private UserMapper usermapper;
    @Override
    public User login(String username, String password) {
        //通过用户名查用户
        User user = usermapper.selectUserByUsername(username);
        //验证用户是否存在，密码是否正确
        if(user != null){
            if(password.equals(user.getPassword())){
                return user;
            }
        }
        return null;
    }
    @Override
    public void updateUser(User user) {
        usermapper.updateUser(user);
    }
}
